Class detection works for huggingface checkpoints #1800
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1798. You can now do
keras_nlp.models.Backbone("hf://google-bert/bert-base-uncased")
with a safetensors checkpoint, are we will find the correct architecture to instantiate. This has always worked for Keras-style checkpoints, but not safetensor ones.This was a tricky one to fix that involved some large refactoring to our preset loading routine.
Originally the intent was that
from_preset()
was a easily readable bunch of lower-level Keras calls. With the arrival of transformers conversions, and soon timm conversions, I think that goal is no longer super realistic. Instead I added a loader interface, with default implementations offload_task
andload_preprocessor
. Every format we support directly converting from has to support at a minimum...One consequence of this work is that every class with a
from_preset
constructor needs to reference thebackbone_cls
they match with. I think this will be a more stable way to handle our "auto class" like functionality as we venture further towards multi-modal models